package com.day20.ex09;

public class SellTicket implements Runnable{
    private static int ticket = 100;
    private int x=0;
    @Override
    public void run() {
        while (true){
            sellTicket();
        }
    }
    private static synchronized void sellTicket(){
        if (ticket>0){
            try{
                Thread.sleep(100);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"正在出售第"+ticket+"张票");
            ticket--;
        }
    }
}
